/*
 *  PMSegment.h
 *  PezMonkey
 *
 *  Created by Spence DiNicolantonio on 12/22/09.
 *  Copyright 2009 Necrosoft. All rights reserved.
 *
 */

#pragma mark Type Definition

/**
 * Defines the PMSegment type.
 */
typedef struct _PMSegment {
	PMVect start;
	PMVect end;
} PMSegment;


#pragma mark -
#pragma mark Static Inline Functions

/**
 * Constructs a PMSegment structure with a given start and end point.
 */
static inline PMSegment PMSegmentMake(const PMVect start, const PMVect end) {
	PMSegment segment;
	segment.start = start;
	segment.end = end;
	return segment;
}

/**
 * Calculates the length of a given segment.
 */
static inline PMFloat PMSegmentLength(const PMSegment segment) {
	return PMVectDist(segment.start, segment.end);
}


#pragma mark -
#pragma mark Other Functions

/** 
 * Creates and returns an NSString object describing a given PMSegment.
 */
static NSString* PMSegmentToString(const PMSegment segment) {
	return [NSString stringWithFormat:@"{(%@), (%@)}, ", 
			PMVectToString(segment.start), 
			PMVectToString(segment.end)];
}
